Skip to content

Swift: Recurse clang submodules when computing extension indexes - #22234

Merged
jketema merged 1 commit into
github:mainfrom
jketema:jketema/swift-fix
Jul 29, 2026
Merged

Swift: Recurse clang submodules when computing extension indexes#22234
jketema merged 1 commit into
github:mainfrom
jketema:jketema/swift-fix

Conversation

@jketema

@jketema jketema commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

I had originally excluded this, as this didn't seem possible. Looks like I was mistaken. The crash on the linked issue is on an extension, not something private.

I just hope this doesn't make things even slower 😅 DCA looks ok.

Fixes: #22224

@github-actions github-actions Bot added the Swift label Jul 27, 2026
@jketema jketema changed the title Swift: Recurse calng submodules when computing extension indexes Swift: Recurse clang submodules when computing extension indexes Jul 27, 2026
@jketema
jketema marked this pull request as ready for review July 27, 2026 11:30
Copilot AI review requested due to automatic review settings July 27, 2026 11:30
@jketema
jketema requested review from a team as code owners July 27, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Recursively indexes extensions and fileprivate values in nested Clang submodules, preventing Swift extraction assertions for deeply nested declarations.

Changes:

  • Adds recursive Clang submodule traversal while preserving index continuity.
  • Removes an unused generated trap-class include.
Show a summary per file
File Description
swift/extractor/mangler/SwiftMangler.h Declares the recursive indexing helper.
swift/extractor/mangler/SwiftMangler.cpp Implements recursive indexing across nested Clang submodules.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

swift::ClangModuleLoader* moduleLoader,
uint32_t index) {
for (const auto& submodule : clangModule->submodules()) {
index = indexClangSubmoduleExtensionsAndFilePrivateValues(submodule, moduleLoader, index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it:

  • previously we were exploring submodules, but not recursively (that's added here).
  • index is used to identify extensions or file private values internally, it is not a Clang number.
  • the submodule structure is guaranteed to be acyclic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • previously we were exploring submodules, but not recursively (that's added here).

Correct.

  • index is used to identify extensions or file private values internally, it is not a Clang number.

Correct. We just count extensions in Swift code separately from extensions that come from C++ code (clang).

  • the submodule structure is guaranteed to be acyclic?

If not that would mean that C++20 modules can import each other cyclically, which is illegal.

@geoffw0 geoffw0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and DCA LGTM also. 👍

@jketema
jketema merged commit 46e738d into github:main Jul 29, 2026
17 checks passed
@jketema
jketema deleted the jketema/swift-fix branch July 29, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

3 participants